package com.soft.javase.day15.annotation;

import org.junit.Test;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/5/27
 */
public class AnnotationTest {

    @Test
    public void testAnnotation() throws NoSuchMethodException {
        Class<BookStore> clazz = BookStore.class;
        Method method = clazz.getDeclaredMethod("purchase");
        if (method.isAnnotationPresent(Book.class)) {
            Book annotation = method.getDeclaredAnnotation(Book.class);
            System.out.println("书名="+annotation.value());
            System.out.println("价格="+annotation.price());
            System.out.println("作者="+ Arrays.toString(annotation.authors()));
        }else {
            System.out.println("purchase()方法上没有Book注解");
        }

    }
}
